# views/base_views.py
from PySide6.QtWidgets import QWidget, QVBoxLayout, QLabel, QPushButton
from PySide6.QtGui import QFont

class SubPage(QWidget):
    """子页面基类，提供通用UI组件（标题、导航按钮等）"""
    def __init__(self, title, event_bus, parent=None):
        super().__init__(parent)
        self.title = title
        self.event_bus = event_bus
        self.init_ui()
        
    def init_ui(self):
        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(20, 20, 20, 20)
        
        # 标题
        title_label = QLabel(self.title)
        title_font = QFont()
        title_font.setPointSize(16)
        title_font.setBold(True)
        title_label.setFont(title_font)
        title_label.setStyleSheet("margin-bottom: 20px; color: #2c3e50;")
        self.layout.addWidget(title_label)
    
    def add_nav_button(self, text, callback):
        """添加导航按钮（统一样式）"""
        btn = QPushButton(text)
        btn.setStyleSheet("""
            QPushButton {
                background-color: #3498db;
                color: white;
                border: none;
                padding: 8px 16px;
                border-radius: 4px;
                margin: 5px 0;
            }
            QPushButton:hover {
                background-color: #2980b9;
            }
        """)
        btn.clicked.connect(callback)
        self.layout.addWidget(btn)
        return btn